package org.opens.controller;

import cn.hutool.json.JSONObject;
import org.opens.aop.aspect.RateLimitAspect;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api/rate")
public class RateLimitController {

    @GetMapping(value = "/{name}")
    @RateLimitAspect
    public JSONObject getTest(
            @PathVariable(value = "name") String name
    ) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.append("message", "hello " + name);
        return jsonObject;
    }

}
